package com.shuoyue.ycgk.ui.mok;

import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.SourtInfo;
import com.shuoyue.ycgk.entity.Unit;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;

public interface MokSourtContract {
    interface View extends BaseView {
        void getSourtSuc(SourtInfo list);

    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();


        public void getSourt(Integer mockId, int n) {
            apply(model.getSourt(mockId, n))
                    .subscribe(new ApiSubscriber<Optional<SourtInfo>>(mView, this) {
                        @Override
                        public void onNext(Optional<SourtInfo> listWithPageOptional) {
                            super.onNext(listWithPageOptional);
                            mView.getSourtSuc(listWithPageOptional.getIncludeNull());
                        }
                    });
        }
    }

    class Model {
        Observable<BaseResult<SourtInfo>> getSourt(Integer mokId, int n) {
            return RetrofitClient.getInstance().getApi().getMokSourt(mokId, n);
        }
    }
}
